<?php session_start();?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
    include "Customer.php";
    include "CustomerDao.php";
    include "Datasource.php";

    $tempCustomer = new Customer();
    $customerDao = new CustomerDao();
    $conn = new Datasource("localhost","theanykey","root","");

    $tempCustomer = $customerDao->getObject($conn, $_GET["id"]);

?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="maintenancePagesCSS.css" />
        <title></title>
    </head>
    <body>

        <center>
          <form name="CustomerForm" action="CustomerEditFunc.php" method="post" id="CustomerForm">

                  <table width="1000" height="624" border="0" background="images/background.jpg">
                  <tr>
                    <th height="490" scope="col"><center>
                      <p><img src="images/TitleCustomerInformation.gif" alt="Customer Information" width="514" height="67"></p>
                      <table border="0" class="EditTable">
                        
                        <tbody>
                          <tr>
                            <td>Customer ID:</td>
                            <td><input type="text" name="CustomerID" value="<?php print($tempCustomer->getCustomerID());  ?>"  size="25" id="CustomerID" disabled="disabled"/>
                                <input type="hidden" name="CustID" value="<?php print($tempCustomer->getCustomerID());  ?>" />                            </td>
                          </tr>
                          <tr>
                            <td>*Last Name:</td>
                            <td><input type="text" name="CustomerLast" value="<?php print($tempCustomer->getLastName());  ?>" size="25" id="CustomerLast" /></td>
                          </tr>
                          <tr>
                            <td>*First Name:</td>
                            <td><input type="text" name="CustomerFirst" value="<?php print($tempCustomer->getFirstName());  ?>" size="25" id="CustomerFirst"/></td>
                          </tr>
                          <tr>
                            <td>Address:</td>
                            <td><input type="text" name="CustomerAddress" value="<?php print($tempCustomer->getAddress());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>City:</td>
                            <td><input type="text" name="CustomerCity" value="<?php print($tempCustomer->getCity());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>State:</td>
                            <td><input type="text" name="CustomerState" value="<?php print($tempCustomer->getState());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>Zip:</td>
                            <td><input type="text" name="CustomerZip" value="<?php print($tempCustomer->getZip());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>*Phone 1:</td>
                            <td><input type="text" name="CustomerPhone1" value="<?php print($tempCustomer->getPhoneNumber1());  ?>" size="25" id="CustomerPhone1"/></td>
                          </tr>
                          <tr>
                            <td>Phone 2:</td>
                            <td><input type="text" name="CustomerPhone2" value="<?php print($tempCustomer->getPhoneNumber2());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>Phone 3:</td>
                            <td><input type="text" name="CustomerPhone3" value="<?php print($tempCustomer->getPhoneNumber3());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td>Email:</td>
                            <td><input type="text" name="CustomerEmail" value="<?php print($tempCustomer->getEmail());  ?>" size="25" /></td>
                          </tr>
                          <tr>
                            <td colspan=2><center>
                                <input type="button" name="Update" value="Update" onClick="submitEditCust();"/>
                                <input type="reset" name="Clear" value="Clear"/>
                            </center></td>
                          </tr>
                        </tbody>
                      </table>
                      <address>
                        * denotes required field
                      </address>
                    </center>
                      <center>
                     <BR><BR>
                  <script src="links.js" language="javascript" type="text/javascript"></script>
                  <script type="text/javascript">
                      writeCustomerLinks("", "");
                  </script>
                      </center>                    </th>
                  </tr>
                  <tr>
                    <th height="128" scope="col">&nbsp;</th>
                  </tr>
                </table>
            </form>
            </center>
        </body>

    <script type="text/javascript">
        function submitEditCust()
        {
            var strCorrect = "Please correct the following errors:\n";
            var strCompare = strCorrect;
            strCorrect += checkFields();
            if(strCorrect == strCompare)
            {
               document.getElementById("CustomerForm").submit();
            }
            else
            {
                alert(strCorrect);
            }
        }

        function checkFields()
        {
            var str = "";

            str += (document.getElementById("CustomerLast").value == "") ? "  - Last Name is Blank\n" : "";

            str += (document.getElementById("CustomerFirst").value == "") ? "  - First Name is Blank\n" : "";

            str += (document.getElementById("CustomerPhone1").value == "") ? "  - User ID is Blank\n" : "";

            return str;
        }
    </script>
</html>
